Soru & Cevap

web service int java.lang.String.lengt() hatası

22.05.2015 - 08:48

Selamlar gelen kutusundaki smsleri sql veritabanına aktarmaya çalışıyorum  log ekranımda  " Attempt to invoke virtual method    ' int java.lang.String.length() ' on a null object reference "  hatası veriyor .  Web servisimde kendim veri girince çalışıyor ancak telefondan bilgi gönderemiyorum sebebi ne olabilir ?

   Uri uriSMSURI = Uri.parse("content://sms/inbox");
		
		
		Cursor cur = getContentResolver().query(uriSMSURI, null, null, null,null);
		String sms = "";
		long tim;
		
		
		if(cur.moveToFirst()){
			do{
				
	
				String date = cur.getString(cur.getColumnIndex("date"));
				Long timestamp = Long.parseLong(date);

				SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy/HH:mm");
				Calendar calendar = Calendar.getInstance();
				calendar.setTimeInMillis(timestamp);
				String finaldate = dateFormat.format(calendar.getTime());
			 String	 smsDate = finaldate.toString();

				//InboxSmsDate=smsDate;
				//				name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));

				InboxSmsFrom=cur.getString(2);
				InboxSmsBody=cur.getString(12);
				InboxSmsDate=smsDate;
				
				
				new ToastMessageTask().execute(InboxSmsDate, InboxSmsBody,InboxSmsFrom);
				
				
				
			}while(cur.moveToNext());
			
			
		}

//////////////////////////////////////////////////////////////////////////////////////



private void inboxsms(String date, String body,String from) {

		SoapObject request = new SoapObject(NAMESPACE3, METHOD_NAME3);

		PropertyInfo DateInfo = new PropertyInfo();
		DateInfo.setName("date");
		DateInfo.setValue(date);

		PropertyInfo BodyInfo = new PropertyInfo();
		BodyInfo.setName("body");
		BodyInfo.setValue(body);
		
		PropertyInfo FromInfo = new PropertyInfo();
		BodyInfo.setName("from");
		BodyInfo.setValue(from);

		request.addProperty(DateInfo);
		request.addProperty(BodyInfo);
		request.addProperty(FromInfo);

		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		envelope.dotNet = true;

		envelope.setOutputSoapObject(request);
		HttpTransportSE httpTransportSE = new HttpTransportSE(URL1);
	
		try {
			
			httpTransportSE.call(SOAP_ACTION3, envelope);
			SoapPrimitive soapPrimitive = (SoapPrimitive) envelope
					.getResponse();

			inboxsmsResult = soapPrimitive.toString();
			Log.e("inboxsmsResult=", inboxsmsResult);
		} catch (Exception e) {
			Log.e("inboxsmsResult", e.getMessage());
		}

	}

 

77 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user osman.asar
osman.asar
14.12.2019 - 12:24

Null konrolü yapmalısınız